package com.gzs.zhdj.mapper;

import com.gzs.zhdj.domain.entity.Organization;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrganizationMapper {
    @Insert("insert into party_organizations(id, name, leader, p_id, org_level) values (#{id},#{name},#{leader},#{pId},#{level})")
    void insertPartyOrg(Organization organization);

    @Update("update party_organizations set leader = #{leader} , p_id = #{pId} where id = #{id}")
    void updatePartyOrg(Organization organization);

    @Select("select leader from party_organizations where name = #{name}")
    String getLeaderByname(String name);

    @Select("select id from party_organizations where name = #{name}")
    int getIdByName(String name);

    @Select("select * from party_organizations")
    List<Organization> getOrgName();

    @Select("select name from party_organizations where id = #{oId}")
    String getOrgNameById(int oId);
}
